<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>流程提醒邮件模板管理</title>
<link
	href="${ctx}/jeasyui-extensions/plugins/ueditor/ue1_4_3-utf8-net/themes/default/css/ueditor.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${ctx}/jeasyui-extensions/plugins/ueditor/ue1_4_3-utf8-net/ueditor.config.js"></script>
<script type="text/javascript"
	src="${ctx}/jeasyui-extensions/plugins/ueditor/ue1_4_3-utf8-net/ueditor.all.js"></script>
<script type="text/javascript"
	src="${ctx}/jeasyui-extensions/plugins/ueditor/ue1_4_3-utf8-net/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript"
	src="${ctx}/jeasyui-extensions/jeasyui-extensions/jquery-easyui-ueditor/jquery.ueditor.js"></script>
<script type="text/javascript">
	var $grid;
	$(function() {
		$grid = $("#grid").datagrid($.extend(datagridOption, {
			url : "${ctx}/bpm/mailTemplate/dataGrid",
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'name',
				title : '模板名称',
				sortable : true
			}, {
				field : 'subject',
				title : '模板标题',
				sortable : true
			}, {
				field : 'content',
				title : '模板内容',
				width : 460,
				styler : function() {
					return "nowrap:false";
				}
			} ] ]
		}));
		$grid.datagrid('enableFilter');

		$("#add").click(function() {
			$("#fm").form("clear");
			$("#dlg").dialog("open").dialog("setTitle", "新增");
		});
		$("#edit").click(function() {
			var rowData = $grid.datagrid("getSelected");
			if (rowData == null) {
				$.messager.show({
					msg : "您未选中行，无法编辑",
					icon : "warning",
					position : "bottomRight"
				});
			} else {
				$("#dlg").dialog("open").dialog("setTitle", "编辑");
				$("#fm").form("load", rowData);
			}
		});
		$("#delete").click(
				function() {
					var rowData = $grid.datagrid("getSelected");
					if (rowData == null) {
						$.messager.show({
							msg : "您未选中行，无法删除",
							icon : "warning",
							position : "bottomRight"
						});
					} else {
						$.messager.confirm("您确定要进行该操作？", function(c) {
							if (c) {
								$.get("${ctx}/bpm/mailTemplate/delete/"
										+ rowData.id, function(result) {
									$.messager.show({
										msg : result.msg,
										icon : "info",
										position : "bottomRight"
									});
									if (result.success) {
										$grid.datagrid("deleteRow", rowData);
									}
								}, 'json');
							}
						});
					}
				});
		$("#explain").text(
				"#" + "{initiator}：流程发起人；#" + "{task.assignee}：任务负责人;#"
						+ "{task.name}：任务名称");
	});
	function fn_save() {
		$("#fm").form("submit", {
			url : "${ctx}/bpm/mailTemplate/update",
			success : function(data) {
				$grid.datagrid("load");
				$.messager.show({
					msg : data.msg,
					icon : "info",
					position : "bottomRight"
				});
				$("#dlg").dialog('close');
			}
		});
	}
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="row">
	<div class="col-md-12">
		<shiro:hasPermission name="bpmMailTemplate:update">
			<button id="add" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-plus"></span> 新增
				</button>
				<button id="edit" type="button" class="btn btn-primary">
					<span class="glyphicon glyphicon-pencil"></span> 编辑
				</button>
		</shiro:hasPermission>
		<shiro:hasPermission name="bpmMailTemplate:delete">
			<button id="delete" type="button" class="btn btn-danger">
					<span class="glyphicon glyphicon-minus"></span> 删除
				</button>
		</shiro:hasPermission>
		</div>
	</div>
	<div id="win"></div>
	<shiro:hasPermission name="bpmMailTemplate:update">
		<div id="dlg" class="easyui-dialog"
			style="width: 710px; height: 495px; padding: 10px 20px"
			data-options="resizable:true,modal:true, buttons:'#dlg-btn',closed:true">
			<form id="fm" method="post">
				<input type="hidden" name="id" />
				
					<table id="tbl">
						<tr>
							<td><label>邮件模板名称:</label></td>
							<td><input name="name" class="easyui-validatebox"
								style="width: 508px" data-options="required:true"></td>
						</tr>
						<tr>
							<td><label>邮件模板标题:</label></td>
							<td><input name="subject" class="easyui-validatebox"
								style="width: 508px" data-options="required:true"></td>
						</tr>
						<tr>
							<td><label>邮件模板内容:</label></td>
							<td><textarea name="content" class="easyui-ueditor"
									data-options="
                              required: true, height: 250,width:508, value: '',
                              template: 'normal',
                              codeMirrorJsUrl: false, codeMirrorCssUrl: false
                              "></textarea></td>
						</tr>
						<tr>
							<td></td>
							<td id="explain" style="color: red"></td>
						</tr>
					</table>
				
			</form>
			<div id="dlg-btn">
				<button id="add" type="button" class="btn btn-primary" onclick="fn_save();">
					<span class="glyphicon glyphicon-ok"></span> 保存
				</button>
				<button id="edit" type="button" class="btn btn-primary" onclick="$('#dlg').dialog('close');">
					<span class="glyphicon glyphicon-remove"></span> 取消
				</button>
			</div>
		</div>
	</shiro:hasPermission>
</body>
</html>
